package com.wiscamp.ninechapters.panels.infrastructure.mappers;

import com.wiscamp.ninechapters.panels.infrastructure.views.OrganizationView;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.util.Collection;

@Repository
public interface OrganizationViewMapper extends JpaRepository<OrganizationView, Long>, JpaSpecificationExecutor<OrganizationView> {

    @Query(value = "select e from OrganizationView e where e.organizationCode = :organizationCode")
    OrganizationView findByOrganizationCode(String organizationCode);

    @Query(value = "select e from OrganizationView e where e.organizationName = :organizationName")
    OrganizationView findByOrganizationName(String organizationName);

    @Query(value = "select e from OrganizationView e where e.enabled")
    Collection<OrganizationView> findListByAvailable();

}